from django.http import HttpResponseRedirect, HttpResponse
from django.template import RequestContext
from django.shortcuts import render_to_response
from rango.bean.beans import TimePoint, Skill,ProjectInfo
from rango.view.category import get_category_list

def about(request):
    context = RequestContext(request)
    
    session = request.session
    
    if session.get('visits'):
        count = int(request.session.get('visits'))
    else:
        count = 0
        
    session['visits'] = count + 1
    
    context_dict = {'str': 'I\'m about page', 'visits': count + 1}
    context_dict['cat_list'] = get_category_list()

    return render_to_response('rango/about.html', context_dict, context)
    
def my_cv(request):
    context = RequestContext(request)
    timeline = []
    timeline.append(TimePoint('1989','http://dummyimage.com/250x200/000/fff',["May 1989, Born in Daklak"]))
    timeline.append(TimePoint('2007','http://dummyimage.com/250x200/000/fff',["Graduated Nguyen Binh Khiem high school","Went to University of Information Technology"]))
    timeline.append(TimePoint('2011','http://dummyimage.com/250x200/000/fff',["Got TOEIC certificate with 820 points"]))
    timeline.append(TimePoint('2012','http://dummyimage.com/250x200/000/fff',["Graduated University of Information Technology","Being unemployed", "Open an online fashion shop"]))
    timeline.append(TimePoint('2013','http://dummyimage.com/250x200/000/fff',["Online shop broke down","September 2013, Worked at NTT Data Vietnam"]))
    timeline.append(TimePoint('2014','http://dummyimage.com/250x200/000/fff',["August 2014, Got Japanese N5 Certificate","December 2014, Left NTT Data Vietnam"]))
    timeline.append(TimePoint('2015','http://dummyimage.com/250x200/000/fff',["January 2015, Work at Systemgear Vietnam"]))
    
    lang_skills = []
    lang_skills.append(Skill('Vietnamese', 95, "Native language"))
    lang_skills.append(Skill('English', 80, "Upper intermediate"))
    lang_skills.append(Skill('Japanese', 30, "Beginner"))
    
    top_skills = []
    top_skills.append(Skill('Java', 82, "Experienced"))
    top_skills.append(Skill('Python', 79, "Self-learning"))
    top_skills.append(Skill('Spring', 75, "Experienced"))
    top_skills.append(Skill('Struts', 50, "Familiar"))
    top_skills.append(Skill('Database', 72, "Experienced"))
    
    soft_skills = []
    soft_skills.append(Skill('Communicate', 50, ""))
    soft_skills.append(Skill('Creativity', 80, ""))
    soft_skills.append(Skill('Problem-solve', 82, ""))
    soft_skills.append(Skill('Teamwork', 72, ""))
    soft_skills.append(Skill('Leadership', 49, ""))
    
    other_skills = [["Android programming", "GUI programming", "HTML/CSS knowledge"],
                    ["Design Pattern", "Basic algorithm", "Django framework"],
                    ["ViSC framework", "Terasoluna framework", "Javascript, JQuery"]]
                    
    projects = []
    projects.append(ProjectInfo('Mylink',"An e-commercial website for selling and gift exchange",
                                ["Spring 2 Framework","Struts 1 Framework","Terasoluna 2 Framework", "Built-in Mylink Framework", "Postgres SQL 9.3"],
                                ["An offshore project from huge customer in Japan",
                                "Part of the ntt-card.com website. One of the biggest website in Japan",
                                "A very successful projects. Received big reward from the Head-quarter",
                                "The customer is very satisfied with the quality, the deadline,...",
                                "A big step for my former company to expand their business"]));
                                
    projects.append(ProjectInfo('ACV Ordering system',"An big ERP project for the ordering and stock managing system",
                                ["Spring 2 Framework","Struts 1 Framework","Terasoluna 3 Framework", "ViSC Framework", "Oracle", "Postgres SQL", "AJAX, JSTL, JSON, JQuery,..."],
                                ["Huge project for Acecook Vietnam, with many function and screen",
                                "Have splendid design inherited from LSeries with many custom features",
                                "Like no others, we use the automation developing (not the testing). One of the firsts",
                                "Multiple language. Can exchange from Japanese, English and Vietnamese with only one click"]));

    projects.append(ProjectInfo('ACV Agent system',"Phase 2 of the ACV ordering system",
                                ["Spring 2 Framework","Struts 1 Framework","Terasoluna 3 Framework", "ViSC Framework", "Oracle", "Postgres SQL", "AJAX, JSTL, JSON, JQuery,..."],
                                ["After the success of ACV Ordering System. The customer ordered a system for their agent",
                                "Also inherited the design from LSeries and add even more function to it",
                                "Help reduce the delivery and selling time of the agent",
                                "Multiple language"]));
    
    context_dict = {'timePoints': timeline, 'langSkills': lang_skills, 
                    'topSkills': top_skills, 'softSkills': soft_skills, 
                    'otherSkills': other_skills,
                    'projects': projects}
    
    return render_to_response('rango/mycv.html', context_dict, context)